" ===============Lua文件内容=================

lua require("core.options")
lua require("core.plugins-setup-lazy")
lua require("core.colorscheme")
lua require("core.keymaps")

lua -- 插件
"lua require("plugins/gutentags")
"""lua require("plugins/lualine")
"""lua require("plugins/dashboard")    -- 启动界面
"""lua -- require("plugins/toggleterm")    -- 终端
"""lua require("plugins/auto-session")    -- 上次会话
"""lua require("plugins/nvim-tree")
"""lua require("plugins/treesitter")
"""lua --require("plugins/lsp")
"""lua --require("plugins/cmp")
"""lua require("plugins/comment")
"""lua require("plugins/autopairs")
"""lua require("plugins/bufferline")
"""lua require("plugins/gitsigns")
"""lua require("plugins/telescope")
"""lua -- require("plugins/markdown-preview")
"""lua -- require("plugins/ultisnip")


" 需要pip安装的: ripgrep, neovim
"
" 每个插件必须带上lazynvim里的opts字段


syntax on
filetype plugin indent on
" =============== Old Vim 内容==============
" call plug#begin()
"
" " Plug 'skywind3000/vim-preview'
" "Plug 'skywind3000/gutentags_plus'
" " Plug 'ludovicchabant/vim-gutentags'
" Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
" "Plug 'mfulz/cscope.nvim'
" Plug 'honza/vim-snippets'
" Plug 'SirVer/ultisnips'
" Plug 'plasticboy/vim-markdown'
" call plug#end()


" ===============UltiSnips==================
let g:UltiSnipsExpandTrigger="<tab>"
" 使用 tab 切换下一个触发点，shit+tab 上一个触发点
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" 使用 UltiSnipsEdit 命令时垂直分割屏幕
let g:UltiSnipsEditSplit="vertical"


" =============Gtags========================
" let $GTAGSLABEL = 'native-pygments'
" let $GTAGSCONF = 'F:/04_Program_files/Gtags/share/gtags/gtags.conf'

" ===============gutentags=================

" gutentags 搜索工程目录的标志，当前文件路径向上递归直到碰到这些文件/目录名
" let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project']

" 所生成的数据文件的名称
" let g:gutentags_ctags_tagfile = '.tags'

" 同时开启 ctags 和 gtags 支持：
" let g:gutentags_modules = []
" if executable('ctags')
" 	let g:gutentags_modules += ['ctags']
" endif
" if executable('gtags-cscope') && executable('gtags')
" 	let g:gutentags_modules += ['gtags_cscope']
" endif
" 
" " 将自动生成的 ctags/gtags 文件全部放入 ~/.cache/tags 目录中，避免污染工程目录
" let g:gutentags_cache_dir = expand('~/.cache/tags')
" 
" " 配置 ctags 的参数，老的 Exuberant-ctags 不能有 --extra=+q，注意
" let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
" let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
" let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
" 
" " 如果使用 universal ctags 需要增加下面一行，老的 Exuberant-ctags 不能加下一行
" let g:gutentags_ctags_extra_args += ['--output-format=e-ctags']
" 
" " 禁用 gutentags 自动加载 gtags 数据库的行为
" let g:gutentags_auto_add_gtags_cscope = 0
" 
" " 检测 ~/.cache/tags 不存在就新建
" if !isdirectory(g:gutentags_cache_dir)
"    silent! call mkdir(s:vim_tags, 'p')
" endif

" set cscopequickfix=s-,c-,d-,i-,t-,e-
"



" ================
" Path to store the cscope files (cscope.files and cscope.out)
" Defaults to '~/.cscope'
let g:cscope_dir = '~/.nvim-cscope'

" Map the default keys on startup
" These keys are prefixed by CTRL+\ <cscope param>
" A.e.: CTRL+\ d for goto definition of word under cursor
" Defaults to off
let g:cscope_map_keys = 1

" Update the cscope files on startup of cscope.
" Defaults to off
let g:cscope_update_on_start = 1

" =================vim-markdown=================

let g:vim_markdown_math = 1
let g:vim_markdown_folding_disabled = 1
let g:tex_flavor='latex'

function! ChineseCount() range
	let save = @z
	silent exec 'normal! gv"zy'
	let text = @z
	let @z = save
	silent exec 'normal! gv'
	let cc = 0
	for char in split(text, '\zs')
		if char2nr(char) >= 0x2000
			let cc += 1
		endif
	endfor
	echo "Count of Chinese charasters is:"
	echo cc
endfunc

vnoremap <F8> :call ChineseCount()<cr>


set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936

" neovim 11 好像去除了这个选项？
" set termencoding=utf-8
set encoding=utf-8

" 我们也可以通过以下方式将TAB的宽度设置为4个空格，保证代码格式看起来更整齐
set ts=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
set termguicolors

if &term =~# '^screen'
    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif

" 设置背景透明
" highlight Normal guibg=NONE ctermbg=None

" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
